package com.dwxt.cdms.controller;

import com.dwxt.cdms.entity.vo.YeYingVO;
import com.dwxt.cdms.service.YeYingDataService;
import com.dwxt.common.base.BaseResult;
import com.dwxt.cdms.base.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping({ "/cdms/yeYing" })
public class YeYingDataController {

   @Autowired
   private YeYingDataService yeYingDataService;

   /**
    * @Description: 接收夜莺数据
    * @param yeYingVO:
    * @return com.dwxt.common.base.BaseResult
    * @author chendq
    * @date 2021/9/16
    */
    @RequestMapping("/receiveData")
    public Map receiveData(@RequestBody YeYingVO yeYingVO)  {
        return yeYingDataService.receiveData(yeYingVO);
    }

    /**
     * @Description: PC端列表查询
     * @param page:
     * @param name:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/9/16
     */
    @RequestMapping("/selectYeYingDataPageGroup")
    public BaseResult selectYeYingDataPageGroup(Page page, String name){
        return yeYingDataService.selectYeYingDataPageGroup(page,name);
    }

    /**
     * @Description: 查询单个用户夜莺数据列表
     * @param page:
     * @param customerId:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/9/16
     */
    @RequestMapping("/selectYeYingDataPage")
    public BaseResult selectYeYingDataPage(Page page,@RequestParam(required = true, name = "customerId") Integer customerId){
        return yeYingDataService.selectYeYingDataPage(page,customerId);
    }

    /**
     * @Description: 根据id查询单个详情
     * @param id:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/18
     */
    @RequestMapping("/selectYeYingDataById")
    public BaseResult selectYeYingDataById(Integer id){
        return yeYingDataService.selectYeYingDataById(id);
    }

    /**
     * @Description:
     * @param customerId:   查询redis中用户最近10条夜莺数据
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/20
     */
    @RequestMapping("/selectYeYingFromRedisById")
    public BaseResult selectYeYingFromRedisById(Integer customerId){
        return yeYingDataService.selectYeYingFromRedisById(customerId);
    }
}
